const Controller = require('../core/base_controller');

class HomeController extends Controller {
  async login() {
    const {ctx,app} = this;
    try{
      const data = await ctx.service.user.login()
      if(typeof data === 'string') {
        this.error(data)
      } else {
        this.success(data)
      }
    } catch(err) {
      this.error(err.message)
    }
  }
  async register() {
    const {ctx,app} = this;
    try{
      const data = await ctx.service.user.register()
      if(typeof data === 'string') {
        this.error(data)
      } else {
        this.success(data)
      }
    } catch(err) {
      this.error(err.message)
    }
  }
}

module.exports = HomeController;